package cn.tangsihai.user.controller;

import cn.tangsihai.basic.util.AjaxResult;
import cn.tangsihai.user.service.IVerifycodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/verifycode")
@Api(value = "短信验证码接口")
public class VerifycodeController {
    @Autowired
    private IVerifycodeService verifycodeService;

    @PostMapping("/smsCode")
    @ApiOperation(value = "发送短信验证码")
    // 前端使用对象作为参数，这里使用Map接收，会自动映射到Map中
    public AjaxResult smsCode(@RequestBody Map<String, String> param){
        try {
            verifycodeService.smsCode(param);
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setMsg("系统繁忙。。。");
        }
    }
}
